<template>
  <div class="item info">
    <p class="title">{{ title }}</p>
    <!-- 修改 -->
    <template v-if="edit">
      <div class="edit" @click="editAccount">
        <img src="@/assets/images/people/edit1.png" alt="" />
        <span>修改</span>
      </div>
    </template>
    <template v-else-if="cEdit">
      <slot name="edit"></slot>
    </template>
    <!-- 内容 -->
    <div class="content" :class="thisColumns">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    // 修改键
    edit: {
      type: Boolean,
      default: false
    },
    // 修改键
    cEdit: {
      type: Boolean,
      default: false
    },
    // 列数
    columns: {
      type: Number,
      default: 1
    },
    title: {
      type: String,
      default: '标题'
    }
  },
  computed: {
    // 列数
    thisColumns() {
      if (this.columns === 2) {
        return 'two'
      } else if (this.columns === 3) {
        return 'three'
      } else {
        return 'one'
      }
    }
  },
  methods: {
    // 点击修改按钮
    editAccount() {
      this.$emit('edit')
    }
  }
}
</script>

<style lang="less" scoped>
.item {
  background-color: #ffffff;
  margin-top: 20px;
  position: relative;
  .title {
    color: #0096ff;
    font-size: 14px;
    font-weight: bold;
    padding: 13px 20px;
    border-bottom: 1px solid #f7f8f9;
  }
  .edit {
    position: absolute;
    right: 20px;
    top: 13px;
    cursor: pointer;
    display: flex;
    img {
      width: 16px;
      height: 16px;
      margin-right: 10px;
    }
    > p {
      color: #f6bb00;
    }
    .ant-btn {
      margin-left: 20px;
      height: 24px;
      transform: translateY(-22%);
    }
  }
  &.info {
    .content {
      padding: 0 20px 20px 20px;
      border-bottom: 1px solid #f7f8f9;
      display: flex;
      flex-wrap: wrap;
      div {
        width: 100%;
        display: flex;
        align-items: center;
        font-size: 14px;
        margin-top: 20px;
        overflow: hidden;
        span {
          color: #a9b2ce;
          display: inline-block;
          width: 100px;
          text-align: right;
        }
        p {
          width: 50%;
          text-overflow: ellipsis;
          overflow: hidden;
          color: #3b4861;
        }
        img {
          width: 20px;
          height: 20px;
          margin-left: 10px;
        }
        &.price {
          display: flex;
          input {
            width: 60px;
            height: 36px;
            padding: 1px 10px;
            background: #ffffff;
            border: 1px solid #e7e7eb;
          }
          a {
            margin-left: 20px;
          }
        }
      }
      .billingItem {
        margin-top: 0;
        flex-wrap: wrap;
        &:not(:last-child) {
          padding-bottom: 20px;
          border-bottom: 1px solid #f7f8f9;
        }
      }
    }
    .two {
      div {
        width: 50%;
      }
    }
    .three {
      div {
        width: 25%;
        &:nth-child(3n + 3) {
          width: 50%;
        }
      }
    }
  }
}
</style>
